<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <base data-ice="baseUrl" href="../../../">
  <title data-ice="title">app/model/TreeSchema.js | API Document</title>
  <link type="text/css" rel="stylesheet" href="css/style.css">
  <link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
  <script src="script/prettify/prettify.js"></script>
  
  
  <script src="script/manual.js"></script>
</head>
<body class="layout-container" data-ice="rootContainer">

<header>
  <a href="./">Home</a>
  
  <a href="identifiers.html">Reference</a>
  <a href="source.html">Source</a>
  
  
  <div class="search-box">
  <span>
    <img src="./image/search.png">
    <span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
  </span>
    <ul class="search-result"></ul>
  </div>
</header>

<nav class="navigation" data-ice="nav"><div>
  <ul>
    
  </ul>
</div>
</nav>

<div class="content" data-ice="content"><h1 data-ice="title">app/model/TreeSchema.js</h1>
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">&apos;use strict&apos;;

module.exports = mongoose =&gt; {
  const TreeSchema = new mongoose.Schema({
    parentId: { type: Int },
    node: { type: String },
    path: { type: String }
  });

  /**
   * data: child data for adding, can be string/object
   * if string, format like a.b.c, should add recursively
   * return: message with adding result, in adding result should contain child model
   * { success: true, affectedRow: 1, child: childModel}
   */
  TreeSchema.methods.addChild = function(data){
    
  }

  /**
   * mode: 
   * leaf - all leaf children
   * next - next level of children
   * all - all children
   * return array of child model
   */
  TreeSchema.methods.getChildren = function(mode){
    
  }

  /**
   * mode: 
   * leaf - all leaf children
   * next - next level of children
   * all - all children
   * return child model or not
   */
  TreeSchema.methods.getChild = function(filterData,mode){
    
  }

  /**
   * mode: 
   * direct - direct parent
   * all - all parents, retrun array
   * return parent model or array of parent model
   */
  TreeSchema.methods.getParent = function(mode){
    
  }

  /**
   * return root node
   */
  TreeSchema.methods.getRoot = function(){
    
  }

  /**
   * parent: should be parent model or object
   */
  TreeSchema.methods.isParent = function(parent){

  }

  /**
   * child: should be child model or object
   */
  TreeSchema.methods.isChild = function(child){

  }

  /**
   * 
   */
  TreeSchema.methods.hasChild = function(){

  }

  return mongoose.model(&apos;Tree&apos;, TreeSchema);
};
</code></pre>

</div>

<footer class="footer">
  Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(0.5.2)</span><img src="./image/esdoc-logo-mini-black.png"></a>
</footer>

<script src="script/search_index.js"></script>
<script src="script/search.js"></script>
<script src="script/pretty-print.js"></script>
<script src="script/inherited-summary.js"></script>
<script src="script/test-summary.js"></script>
<script src="script/inner-link.js"></script>
<script src="script/patch-for-local.js"></script>
</body>
</html>
